package com.example.xjy.zyfypt_407xjy.fragment;

import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v7.widget.LinearLayoutManager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.TextView;

import com.example.xjy.zyfypt_407xjy.R;
import com.example.xjy.zyfypt_407xjy.activity.LoginActivity;
import com.example.xjy.zyfypt_407xjy.adapter.ProjectAdapter;
import com.example.xjy.zyfypt_407xjy.bean.ProjectBean;

import java.util.List;

import static android.content.Context.MODE_PRIVATE;

public class Fragment6 extends Fragment implements View.OnClickListener {
    private View view=null;
    private Context context;
    private TextView tvname;
    private Button btlogout;
    private SharedPreferences sp;
    private String realname;

    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        context = getActivity();
        //动态加载Fragment3的布局文件
        view = inflater.inflate(R.layout.fragment6, container, false);
        sp = context.getSharedPreferences("login", MODE_PRIVATE);
        readRealname();
        init();
        tvname.setText(realname);
        //返回动态生成的view
        return view;
    }

    private void readRealname() {
        realname=sp.getString("realname",null);
    }

    private void init() {
        tvname=(TextView)view.findViewById(R.id.textView13);
        btlogout=(Button)view.findViewById(R.id.logoutbutton);
        btlogout.setOnClickListener(this);


    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.logoutbutton:
                Intent intent=new Intent(getActivity(),LoginActivity.class);
                startActivity(intent);
                break;
        }
    }
}
